package com.gjy.convert;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-11-18 10:52:08
 */
public class PojoToJsonConvert implements Convert<Pojo, String> {

    @Override
    public String convert(Pojo pojo) {
        ObjectMapper om = new ObjectMapper();
        try {
            return om.writeValueAsString(pojo);
        } catch (JsonProcessingException e) {
            return "{}";
        }
    }
}